from flask import Flask
from app.models.book import db

def create_app():
    # 实例化flask,创建核心对象
    myapp = Flask(__name__)

    # from_object()接受模块的路径,载入配置文件
    myapp.config.from_object('app.secure')
    myapp.config.from_object('app.setting')
    register_bp(myapp)
    db.init_app(myapp)
    db.create_all(app=myapp)  # 生成数据表
    return myapp


def register_bp(myapp):
    from app.web import web
    myapp.register_blueprint(web)

